PROJECTENGRAM

[PS] MICROPROGRAMMING AND CONTROL UNIT

Tags: #◇Computer Science #◇CSARCH2 #◇Computer Architecture #◇Microprogramming #◇Control Unit #◇Single-Bus CPU Architecture #◇Register Transfer Language #◇Control Words #◇x86 Assembly #◇Addressing Modes


Problem Set: Microprogramming & Control Unit Design

◇Overview & Theoretical Framework

In a microprogrammed ◇Control Unit, machine-level assembly instructions are not executed by hardwired combinatorial logic alone. Instead, each machine instruction is interpreted as a sequence of elementary hardware operations known as micro-operations (or RTL — Register Transfer Language statements). These micro-operations are stored in a high-speed internal read-only or read-mostly memory called the Control Memory (CM).

『』
TEXT
                    ┌────────────────────────────┐
                    │    Instruction Register    │
                    │            (IR)            │
                    └─────────────┬──────────────┘
                                  │ (Opcode)
                                  ▼
                    ┌────────────────────────────┐
                    │       Mapping Logic        │
                    └─────────────┬──────────────┘
                                  │
                                  ▼
      ┌────────────┐       ┌──────────────┐
      │ SBR (Stack)│ ◄───► │  CAR / $\mu$PC   │ ◄─── Next Address Logic (MUX)
      └────────────┘       └──────┬───────┘
                                  │
                                  ▼
                    ┌────────────────────────────┐
                    │       Control Memory       │
                    │        (Micro-Store)       │
                    └─────────────┬──────────────┘
                                  │
                                  ▼
                    ┌────────────────────────────┐
                    │    Microinstruction /      │
                    │   Control Buffer Register  │
                    └─────────────┬──────────────┘
                                  │
         ┌────────────────────────┴────────────────────────┐
         ▼                                                 ▼
  Control Signals                                  Sequencing Fields
  (Gating, ALU, Memory)                            (CD, BR, Address)

1. The Single-Bus CPU Architecture

The reference architecture investigated in this problem set is a classic Single-Bus Central Processing Unit (CPU). In this organization:

  • A single internal common data bus connects all internal CPU registers, the Arithmetic and Logic Unit (ALU), and the internal interfaces of the Memory Bus.
  • Bus Contention Constraint: At any given clock cycle, at most one register or functional unit may place data onto the bus (Sourceout\text{Source}_{out}). However, multiple registers or listening units may simultaneously latch data from the bus (Destinationin\text{Destination}_{in}).
  • Gating Signals: Every register RkR_k is equipped with tri-state output gating (Rk,outR_{k,out}) and input enable gating (Rk,inR_{k,in}).
『』
TEXT
                             Internal CPU Bus
    ═══════════════════════════════════════════════════════════════════
       ▲  │           ▲  │           ▲  │          ▲           │   ▲
       │  ▼           │  ▼           │  ▼          │           ▼   │
     ┌──────┐       ┌──────┐       ┌──────┐     ┌─────┐     ┌────┐ │
     │  PC  │       │ MAR  │       │ MDR  │     │ IR  │     │ Y  │ │
     └──┬───┘       └──┬───┘       └──┬───┘     └──┬──┘     └─┬──┘ │
      PCout/in      MARin        MDRout/in        IRin        Yin  │
                       │              │                            │
                       ▼              ▼                            ▼
                 [Address Bus]   [Data Bus]                 [MUX Input A]
                 ──────────────────────────                 (SelectY / Select4)
                        External Memory Bus                        │
                                                                   ▼
                                                             ┌──────────┐
               Internal Bus (Input B) ─────────────────────► │   ALU    │
                                                             └────┬─────┘
                                                                  │
                                                                  ▼ Zin
                                                             ┌──────────┐
                                                             │    Z     │
                                                             └────┬─────┘
                                                                  │ Zout
                                                                  ▼
    ═══════════════════════════════════════════════════════════════════

2. Primary Functional Components

ComponentIdentifierArchitectural Function & Gating Characteristics
Program CounterPC\text{PC}Holds the memory address of the next machine instruction to be fetched. Gated via PCout\text{PC}_{out} and PCin\text{PC}_{in}.
Memory Address RegisterMAR\text{MAR}Holds the physical address sent over the external address bus. Latched via MARin\text{MAR}_{in}.
Memory Data RegisterMDR\text{MDR}Dual-ported interface register between internal CPU bus (MDRin,MDRout\text{MDR}_{in}, \text{MDR}_{out}) and external data lines.
Instruction RegisterIR\text{IR}Stores the current instruction byte/word. Supplies the Opcode to mapping logic, IRAFout\text{IRAF}_{out} (Address Field/Displacement), and IRDFout\text{IRDF}_{out} (Data Field/Immediate).
Temporary / Latch RegisterY\text{Y}Latches the first ALU operand from the bus (Yin\text{Y}_{in}). Directly feeds Input A of the ALU via a 2-to-1 Multiplexer.
ALU MultiplexerMUX\text{MUX}Selects between the contents of register Y\text{Y} (SelectY\text{SelectY}) and a hardwired constant 4 (Select4\text{Select4}, used for PC and pointer updates).
ALU Output RegisterZ\text{Z}Latches the raw output of the ALU (Zin\text{Z}_{in}) at the end of the clock cycle, and drives the internal bus via Zout\text{Z}_{out}.
General Purpose RegistersR0…Rn−1R_0 \dots R_{n-1}Programmer-visible registers (e.g., in x86: RAX,RBX,RCX,RDX,RSI,RDI,RSP,RBP\text{RAX}, \text{RBX}, \text{RCX}, \text{RDX}, \text{RSI}, \text{RDI}, \text{RSP}, \text{RBP}).
Control Address RegisterCAR\text{CAR}Internal microprogram counter holding the address of the next microinstruction in Control Memory.
Subroutine RegisterSBR\text{SBR}Holds the return address for microprogram subroutine calls.

3. Fundamental Control Signals & Operations

  1. Register Transfer:
    Sourceout,  Destinationin\text{Source}_{out},\; \text{Destination}_{in}
  2. ALU Operations:
    • Binary Operation: Source1out,  Yin\text{Source1}_{out},\; \text{Y}_{in} followed by Source2out,  SelectY,  ALU_OP,  Zin\text{Source2}_{out},\; \text{SelectY},\; \text{ALU\_OP},\; \text{Z}_{in}, then Zout,  Destinationin\text{Z}_{out},\; \text{Destination}_{in}.
    • Unary Operation: Sourceout,  Set carry-in,  ADD,  Zin\text{Source}_{out},\; \text{Set carry-in},\; \text{ADD},\; \text{Z}_{in}.
    • Mathematical Convention: Addition=Bus+Input A+cin\text{Addition} = \text{Bus} + \text{Input A} + c_{in}; Subtraction=Bus−Input A−cin\text{Subtraction} = \text{Bus} - \text{Input A} - c_{in}.
  3. Memory Fetch:
    Addressout,  MARin,  READ,  WMFC\text{Address}_{out},\; \text{MAR}_{in},\; \text{READ},\; \text{WMFC}
    MDRout,  Destinationin\text{MDR}_{out},\; \text{Destination}_{in}
    (where WMFC\text{WMFC} denotes Wait for Memory Function Complete).
  4. Memory Store:
    Addressout,  MARin\text{Address}_{out},\; \text{MAR}_{in}
    Dataout,  MDRin,  WRITE,  WMFC\text{Data}_{out},\; \text{MDR}_{in},\; \text{WRITE},\; \text{WMFC}
  5. Instruction Termination: END\text{END} resets micro-sequencing to initiate the Fetch Phase of the next instruction.

4. Standard Fetch Phase Microprogram

Every instruction in this architecture begins with an identical 3-cycle Fetch Phase, which retrieves the opcode from memory and increments the Program Counter (PC←PC+4\text{PC} \leftarrow \text{PC} + 4):

Step 1:PCout,  MARin,  READ,  Select4,  ADD,  ZinStep 2:Zout,  PCin,  WMFCStep 3:MDRout,  IRin\begin{aligned} \text{Step 1:}\quad & \text{PC}_{out},\; \text{MAR}_{in},\; \text{READ},\; \text{Select4},\; \text{ADD},\; \text{Z}_{in} \\ \text{Step 2:}\quad & \text{Z}_{out},\; \text{PC}_{in},\; \text{WMFC} \\ \text{Step 3:}\quad & \text{MDR}_{out},\; \text{IR}_{in} \end{aligned}

  • Step 1: The current PC\text{PC} is driven onto the bus. It simultaneously loads the MAR\text{MAR} to initiate the memory read cycle (READ\text{READ}) and enters ALU Input B. The MUX selects constant 4 (Select4\text{Select4}), the ALU adds them (ADD\text{ADD}), and the incremented address (PC+4\text{PC}+4) is latched into Z\text{Z} (Zin\text{Z}_{in}).
  • Step 2: Z\text{Z} is driven onto the bus to update PC\text{PC} (PCin\text{PC}_{in}). The CPU asserts WMFC\text{WMFC} to synchronize with external memory.
  • Step 3: Once memory asserts MFC\text{MFC}, MDR\text{MDR} places the fetched instruction word onto the bus to load the Instruction Register (IRin\text{IR}_{in}).

5. Control Word & Microinstruction Bitfield Layout

To represent microinstructions in binary, we define a standard 32-bit horizontal/vertical control word structure:

SRC_OUTDST_IN1DST_IN2ALU_OPMUXMEMWMFCCDBRAD[31:27][26:22][21:18][17:15][14:13][12:11][10][9:8][7:6][5:0]\begin{array}{|c|c|c|c|c|c|c|c|c|c|} \hline \mathbf{SRC\_OUT} & \mathbf{DST\_IN1} & \mathbf{DST\_IN2} & \mathbf{ALU\_OP} & \mathbf{MUX} & \mathbf{MEM} & \mathbf{WMFC} & \mathbf{CD} & \mathbf{BR} & \mathbf{AD} \\ {[31:27]} & [26:22] & [21:18] & [17:15] & [14:13] & [12:11] & [10] & [9:8] & [7:6] & [5:0] \\ \hline \end{array}

『』
TEXT
 31      27 26      22 21    18 17    15 14  13 12  11  10  9  8  7  6  5          0
┌──────────┬──────────┬────────┬────────┬──────┬──────┬───┬─────┬─────┬─────────────┐
│ SRC_OUT  │ DST_IN1  │ DST_IN2│ ALU_OP │ MUX  │ MEM  │ W │ CD  │ BR  │     AD      │
│ (5 bits) │ (5 bits) │(4 bits)│(3 bits)│(2 b) │(2 b) │(1)│(2 b)│(2 b)│  (6 bits)   │
└──────────┴──────────┴────────┴────────┴──────┴──────┴───┴─────┴─────┴─────────────┘

Field Encodings:

  • SRC_OUT\text{SRC\_OUT} (5 bits): 00000 = None, 00001 = PCout\text{PC}_{out}, 00010 = MDRout\text{MDR}_{out}, 00011 = Zout\text{Z}_{out}, 00100 = RSIout/ESIout\text{RSI}_{out} / \text{ESI}_{out}, 00101 = RBXout/EBXout\text{RBX}_{out} / \text{EBX}_{out}, 00110 = RAXout/EAXout\text{RAX}_{out} / \text{EAX}_{out}, 00111 = RSPout/ESPout\text{RSP}_{out} / \text{ESP}_{out}, 01000 = IRAFout\text{IRAF}_{out}, 01001 = IRDFout\text{IRDF}_{out}, 01010 = TEMPout\text{TEMP}_{out}.
  • DST_IN1\text{DST\_IN1} (5 bits): 00000 = None, 00001 = PCin\text{PC}_{in}, 00010 = MARin\text{MAR}_{in}, 00011 = MDRin\text{MDR}_{in}, 00100 = IRin\text{IR}_{in}, 00101 = Yin\text{Y}_{in}, 00110 = RAXin/EAXin\text{RAX}_{in} / \text{EAX}_{in}, 00111 = RBXin/EBXin\text{RBX}_{in} / \text{EBX}_{in}, 01000 = RDIin/EDIin\text{RDI}_{in} / \text{EDI}_{in}, 01001 = RSPin/ESPin\text{RSP}_{in} / \text{ESP}_{in}, 01010 = TEMPin\text{TEMP}_{in}, 01011 = RDXin/EDXin\text{RDX}_{in} / \text{EDX}_{in}.
  • DST_IN2\text{DST\_IN2} (4 bits): 0000 = None, 0001 = PCin\text{PC}_{in}, 0010 = MARin\text{MAR}_{in}, 0011 = MDRin\text{MDR}_{in}, 0100 = EDXin\text{EDX}_{in}.
  • ALU_OP\text{ALU\_OP} (3 bits): 000 = NOP, 001 = ADD\text{ADD}, 010 = SUB\text{SUB}, 011 = MUL\text{MUL}, 100 = XOR\text{XOR}, 101 = PASS\text{PASS}.
  • MUX\text{MUX} (2 bits): 00 = None, 01 = SelectY\text{SelectY}, 10 = Select4\text{Select4}, 11 = Select8\text{Select8}.
  • MEM\text{MEM} (2 bits): 00 = NOP, 01 = READ\text{READ}, 10 = WRITE\text{WRITE}.
  • W\text{W} (WMFC\text{WMFC}, 1 bit): 0 = No wait, 1 = Assert WMFC\text{WMFC}.
  • CD\text{CD} (Condition Code, 2 bits): 00 = Unconditional, 01 = Test Carry (CF\text{CF}), 10 = Test Zero (ZF\text{ZF}), 11 = Test MFC\text{MFC}.
  • BR\text{BR} (Branch Control, 2 bits): 00 = Next microinstruction (CAR←CAR+1\text{CAR} \leftarrow \text{CAR}+1), 01 = Call Subroutine (SBR←CAR+1,CAR←AD\text{SBR} \leftarrow \text{CAR}+1, \text{CAR} \leftarrow \text{AD}), 10 = Return from Subroutine (CAR←SBR\text{CAR} \leftarrow \text{SBR}), 11 = Map Opcode (CAR←MAP(IR)\text{CAR} \leftarrow \text{MAP}(\text{IR})).
  • AD\text{AD} (Address Field, 6 bits): Target address for micro-jumps/calls (0000002000000_2 to 1111112111111_2).

◇Problem Set Solutions & Detailed Traces


Problem A: Complex SIB Address Calculation — LEA EDI, [ALPHA+RBX+RSI*4]

1. Problem Statement & Operational Semantics

Write the microprogram sequence for the instruction:
LEA EDI, [ALPHA+RBX+RSI×4]\mathbf{LEA\ EDI,\ [ALPHA + RBX + RSI \times 4]}
Note: The fetch instruction cycle (Steps 1–3) may be skipped.

  • Instruction Name: Load Effective Address (LEA\text{LEA}).
  • Destination Register: EDI\text{EDI} (32-bit Destination Index Register).
  • Source Operand: Scale-Index-Base (SIB\text{SIB}) displacement address:
    Effective Address (EA)=Displacement (ALPHA)+Base (RBX)+(Index (RSI)×Scale (4))\text{Effective Address (EA)} = \text{Displacement (ALPHA)} + \text{Base (RBX)} + (\text{Index (RSI)} \times \text{Scale (4)})
  • Crucial Architectural Distinction: Unlike a MOV\text{MOV} instruction referencing memory (MOV EDI, [addr]\text{MOV EDI, [addr]}), LEA\text{LEA} computes the mathematical address and directly places the result into the destination register without generating any memory bus access signals (MARin,READ,WRITE,WMFC,MDRin/out\text{MAR}_{in}, \text{READ}, \text{WRITE}, \text{WMFC}, \text{MDR}_{in/out} are NOT invoked).

2. Step-by-Step Derivation & Gating Analysis

  1. Step 4: Scale the Index Register

    • The index register RSI\text{RSI} is driven onto the bus (RSIout\text{RSI}_{out}).
    • The ALU MUX selects constant 4 (Select4\text{Select4}).
    • The ALU performs multiplication (MUL\text{MUL}), calculating RSI×4\text{RSI} \times 4.
    • The product is latched into the ALU output register Z\text{Z} (Zin\text{Z}_{in}).
    • RTL: RSIout,  Select4,  MUL,  Zin\text{RSI}_{out},\; \text{Select4},\; \text{MUL},\; \text{Z}_{in}
  2. Step 5: Transfer Scaled Index to Latch Register Y\text{Y}

    • The product in Z\text{Z} is driven onto the internal bus (Zout\text{Z}_{out}).
    • The latch register Y\text{Y} latches the value from the bus (Yin\text{Y}_{in}).
    • RTL: Zout,  Yin\text{Z}_{out},\; \text{Y}_{in}
  3. Step 6: Add Base Register RBX\text{RBX}

    • The base register RBX\text{RBX} is driven onto the bus (RBXout\text{RBX}_{out}), entering ALU Input B.
    • The MUX selects register Y\text{Y} (SelectY\text{SelectY}), supplying (RSI×4)(\text{RSI} \times 4) to ALU Input A.
    • The ALU performs addition (ADD\text{ADD}), computing RBX+(RSI×4)\text{RBX} + (\text{RSI} \times 4).
    • The sum is latched into Z\text{Z} (Zin\text{Z}_{in}).
    • RTL: RBXout,  SelectY,  ADD,  Zin\text{RBX}_{out},\; \text{SelectY},\; \text{ADD},\; \text{Z}_{in}
  4. Step 7: Transfer Intermediate Sum to Latch Register Y\text{Y}

    • The sum in Z\text{Z} is driven onto the bus (Zout\text{Z}_{out}).
    • Register Y\text{Y} latches the value (Yin\text{Y}_{in}).
    • RTL: Zout,  Yin\text{Z}_{out},\; \text{Y}_{in}
  5. Step 8: Add Displacement ALPHA\text{ALPHA}

    • The instruction decoder outputs the address displacement field ALPHA\text{ALPHA} onto the bus (IRAFout\text{IRAF}_{out}).
    • The MUX selects register Y\text{Y} (SelectY\text{SelectY}).
    • The ALU performs addition (ADD\text{ADD}), calculating ALPHA+[RBX+(RSI×4)]\text{ALPHA} + [\text{RBX} + (\text{RSI} \times 4)].
    • The final Effective Address is latched into Z\text{Z} (Zin\text{Z}_{in}).
    • RTL: IRAFout,  SelectY,  ADD,  Zin\text{IRAF}_{out},\; \text{SelectY},\; \text{ADD},\; \text{Z}_{in}
  6. Step 9: Store Effective Address into Destination Register EDI\text{EDI}

    • The final effective address in Z\text{Z} is driven onto the bus (Zout\text{Z}_{out}).
    • Destination register EDI\text{EDI} latches the address from the bus (EDIin\text{EDI}_{in}).
    • The micro-routine asserts the END\text{END} control signal to conclude execution.
    • RTL: Zout,  EDIin,  END\text{Z}_{out},\; \text{EDI}_{in},\; \text{END}

3. Microprogram Execution Table

StepMicroinstruction Address (CAR\text{CAR})Active Control SignalsRegister Transfer Language (RTL\text{RTL})Bus Master (Out\text{Out})Bus Listeners (In\text{In})ALU & Memory Action
4000100 (0x040x04)RSIout,Select4,MUL,Zin\text{RSI}_{out}, \text{Select4}, \text{MUL}, \text{Z}_{in}Z←RSI×4\text{Z} \leftarrow \text{RSI} \times 4RSI\text{RSI}ALU Input BALU=Bus×4→Z\text{ALU} = \text{Bus} \times 4 \to \text{Z}
5000101 (0x050x05)Zout,Yin\text{Z}_{out}, \text{Y}_{in}Y←Z\text{Y} \leftarrow \text{Z}Z\text{Z}Y\text{Y}Transfer scaled index to Y\text{Y}
6000110 (0x060x06)RBXout,SelectY,ADD,Zin\text{RBX}_{out}, \text{SelectY}, \text{ADD}, \text{Z}_{in}Z←RBX+Y\text{Z} \leftarrow \text{RBX} + \text{Y}RBX\text{RBX}ALU Input BALU=RBX+(RSI×4)→Z\text{ALU} = \text{RBX} + (\text{RSI} \times 4) \to \text{Z}
7000111 (0x070x07)Zout,Yin\text{Z}_{out}, \text{Y}_{in}Y←Z\text{Y} \leftarrow \text{Z}Z\text{Z}Y\text{Y}Transfer base+scaled index to Y\text{Y}
8001000 (0x080x08)IRAFout,SelectY,ADD,Zin\text{IRAF}_{out}, \text{SelectY}, \text{ADD}, \text{Z}_{in}Z←IRAF+Y\text{Z} \leftarrow \text{IRAF} + \text{Y}IRAF\text{IRAF}ALU Input BALU=ALPHA+Y→Z\text{ALU} = \text{ALPHA} + \text{Y} \to \text{Z}
9001001 (0x090x09)Zout,EDIin,END\text{Z}_{out}, \text{EDI}_{in}, \text{END}EDI←Z,  END\text{EDI} \leftarrow \text{Z},\; \text{END}Z\text{Z}EDI\text{EDI}Load final EA into EDI\text{EDI}, End

4. Binary Control Word Encodings

StepSRC_OUTDST1DST2ALUMUXMEMWCDBRADHex WordStep 400100 (RSI)000000000011 (MUL)10 (Sel4)00000000001010x2001C005Step 500011 (Z)00101 (Y)0000000 (NOP)0000000000001100x19400006Step 600101 (RBX)000000000001 (ADD)01 (SelY)00000000001110x2800A007Step 700011 (Z)00101 (Y)0000000 (NOP)0000000000010000x19400008Step 801000 (IRAF)000000000001 (ADD)01 (SelY)00000000010010x4000A009Step 900011 (Z)01000 (EDI)0000000 (NOP)0000000000000000x1A000000\begin{array}{|c|c|c|c|c|c|c|c|c|c|c|c|} \hline \textbf{Step} & \textbf{SRC\_OUT} & \textbf{DST1} & \textbf{DST2} & \textbf{ALU} & \textbf{MUX} & \textbf{MEM} & \textbf{W} & \textbf{CD} & \textbf{BR} & \textbf{AD} & \textbf{Hex Word} \\ \hline \text{Step 4} & 00100\ (\text{RSI}) & 00000 & 0000 & 011\ (\text{MUL}) & 10\ (\text{Sel4}) & 00 & 0 & 00 & 00 & 000101 & \mathbf{0x2001C005} \\ \text{Step 5} & 00011\ (\text{Z}) & 00101\ (\text{Y}) & 0000 & 000\ (\text{NOP}) & 00 & 00 & 0 & 00 & 00 & 000110 & \mathbf{0x19400006} \\ \text{Step 6} & 00101\ (\text{RBX}) & 00000 & 0000 & 001\ (\text{ADD}) & 01\ (\text{SelY}) & 00 & 0 & 00 & 00 & 000111 & \mathbf{0x2800A007} \\ \text{Step 7} & 00011\ (\text{Z}) & 00101\ (\text{Y}) & 0000 & 000\ (\text{NOP}) & 00 & 00 & 0 & 00 & 00 & 001000 & \mathbf{0x19400008} \\ \text{Step 8} & 01000\ (\text{IRAF}) & 00000 & 0000 & 001\ (\text{ADD}) & 01\ (\text{SelY}) & 00 & 0 & 00 & 00 & 001001 & \mathbf{0x4000A009} \\ \text{Step 9} & 00011\ (\text{Z}) & 01000\ (\text{EDI}) & 0000 & 000\ (\text{NOP}) & 00 & 00 & 0 & 00 & 00 & 000000 & \mathbf{0x1A000000} \\ \hline \end{array}


Problem B: Subroutine Invocation — CALL L1

1. Problem Statement & Operational Semantics

Write the microprogram sequence for the instruction:
CALL L1\mathbf{CALL\ L1}
Note: The fetch instruction cycle (Steps 1–3) may be skipped.

  • Instruction Name: Subroutine Call (CALL\text{CALL}).
  • Target Label: L1\text{L1} (Subroutine entry point).
  • Core Operations:
    1. Stack Pointer Decrement: In x86 architecture, the stack grows downwards towards lower memory addresses. The stack pointer (ESP/RSP\text{ESP} / \text{RSP}) must be decremented by 4 bytes (in 32-bit mode) or 8 bytes (in 64-bit mode).
    2. Push Return Address: The current contents of the Program Counter (PC\text{PC}), which points to the next instruction immediately following the CALL\text{CALL}, must be written into memory at [ESPnew][\text{ESP}_{new}].
    3. Branch to Target Subroutine: The Program Counter (PC\text{PC}) must be updated with the target address of label L1\text{L1}.

2. Derivation of Variants (Absolute vs. Relative CALL)

Depending on the instruction encoding format, CALL\text{CALL} can be implemented as an Absolute Call (where the full target address is provided in the instruction address field) or a Relative Call (where a signed offset is added to the current PC\text{PC}).

Variant B.1: Absolute Direct CALL (L1\text{L1} supplied via IRAFout\text{IRAF}_{out})
  1. Step 4: Decrement Stack Pointer

    • The current stack pointer is driven onto the bus (ESPout\text{ESP}_{out}).
    • The MUX selects constant 4 (Select4\text{Select4}).
    • The ALU performs subtraction (SUB\text{SUB}), calculating ESP−4\text{ESP} - 4.
    • The new top-of-stack address is latched into Z\text{Z} (Zin\text{Z}_{in}).
    • RTL: ESPout,  Select4,  SUB,  Zin\text{ESP}_{out},\; \text{Select4},\; \text{SUB},\; \text{Z}_{in}
  2. Step 5: Update ESP\text{ESP} and Address Memory

    • The decremented address in Z\text{Z} is driven onto the bus (Zout\text{Z}_{out}).
    • It is simultaneously latched back into the stack pointer (ESPin\text{ESP}_{in}) and into the Memory Address Register (MARin\text{MAR}_{in}).
    • RTL: Zout,  ESPin,  MARin\text{Z}_{out},\; \text{ESP}_{in},\; \text{MAR}_{in}
  3. Step 6: Write Return Address (PC\text{PC}) to Stack Memory

    • The Program Counter (PC\text{PC}, holding the return address) is driven onto the bus (PCout\text{PC}_{out}).
    • The Memory Data Register latches the return address from the bus (MDRin\text{MDR}_{in}).
    • The Control Unit initiates a memory write cycle (WRITE\text{WRITE}) and asserts WMFC\text{WMFC}.
    • RTL: PCout,  MDRin,  WRITE,  WMFC\text{PC}_{out},\; \text{MDR}_{in},\; \text{WRITE},\; \text{WMFC}
  4. Step 7: Load Subroutine Target Address into PC\text{PC}

    • The instruction decoder drives the target address L1\text{L1} from the instruction address field onto the bus (IRAFout\text{IRAF}_{out}).
    • The Program Counter latches the target address (PCin\text{PC}_{in}).
    • The micro-routine asserts END\text{END}.
    • RTL: IRAFout,  PCin,  END\text{IRAF}_{out},\; \text{PC}_{in},\; \text{END}

Variant B.2: Relative Near CALL (L1\text{L1} offset supplied via IRDFout\text{IRDF}_{out})

When the target address is encoded as a relative displacement:

  • Step 4: ESPout,  Select4,  SUB,  Zin\text{ESP}_{out},\; \text{Select4},\; \text{SUB},\; \text{Z}_{in}
  • Step 5: Zout,  ESPin,  MARin\text{Z}_{out},\; \text{ESP}_{in},\; \text{MAR}_{in}
  • Step 6: PCout,  MDRin,  WRITE\text{PC}_{out},\; \text{MDR}_{in},\; \text{WRITE} (Write initiated; memory cycle runs in background)
  • Step 7: IRDFout,  Yin\text{IRDF}_{out},\; \text{Y}_{in} (Offset loaded into Y\text{Y})
  • Step 8: PCout,  SelectY,  ADD,  Zin,  WMFC\text{PC}_{out},\; \text{SelectY},\; \text{ADD},\; \text{Z}_{in},\; \text{WMFC} (ALU calculates PC+offset\text{PC} + \text{offset} while waiting for memory write completion)
  • Step 9: Zout,  PCin,  END\text{Z}_{out},\; \text{PC}_{in},\; \text{END}

3. Microprogram Execution Table (Absolute CALL)

StepCAR\text{CAR}Active Control SignalsRegister Transfer Language (RTL\text{RTL})Bus MasterBus ListenersFunctional Action
4000100ESPout,Select4,SUB,Zin\text{ESP}_{out}, \text{Select4}, \text{SUB}, \text{Z}_{in}Z←ESP−4\text{Z} \leftarrow \text{ESP} - 4ESP\text{ESP}ALU Input BDecrement stack pointer by 4
5000101Zout,ESPin,MARin\text{Z}_{out}, \text{ESP}_{in}, \text{MAR}_{in}ESP←Z,  MAR←Z\text{ESP} \leftarrow \text{Z},\; \text{MAR} \leftarrow \text{Z}Z\text{Z}ESP,MAR\text{ESP}, \text{MAR}Update ESP\text{ESP} & stage address in MAR\text{MAR}
6000110PCout,MDRin,WRITE,WMFC\text{PC}_{out}, \text{MDR}_{in}, \text{WRITE}, \text{WMFC}MDR←PC,  [MAR]←MDR\text{MDR} \leftarrow \text{PC},\; [\text{MAR}] \leftarrow \text{MDR}PC\text{PC}MDR\text{MDR}Stage return address & write to RAM
7000111IRAFout,PCin,END\text{IRAF}_{out}, \text{PC}_{in}, \text{END}PC←IRAF,  END\text{PC} \leftarrow \text{IRAF},\; \text{END}IRAF\text{IRAF}PC\text{PC}Update PC\text{PC} to subroutine L1\text{L1}, End

4. Binary Control Word Encodings (Absolute CALL)

StepSRC_OUTDST1DST2ALUMUXMEMWCDBRADHex WordStep 400111 (ESP)000000000010 (SUB)10 (Sel4)00000000001010x38014005Step 500011 (Z)01001 (ESP)0010 (MAR)000 (NOP)0000000000001100x1A480006Step 600001 (PC)00011 (MDR)0000000 (NOP)0010 (WR)100000001110x08C01407Step 701000 (IRAF)00001 (PC)0000000 (NOP)0000000000000000x40400000\begin{array}{|c|c|c|c|c|c|c|c|c|c|c|c|} \hline \textbf{Step} & \textbf{SRC\_OUT} & \textbf{DST1} & \textbf{DST2} & \textbf{ALU} & \textbf{MUX} & \textbf{MEM} & \textbf{W} & \textbf{CD} & \textbf{BR} & \textbf{AD} & \textbf{Hex Word} \\ \hline \text{Step 4} & 00111\ (\text{ESP}) & 00000 & 0000 & 010\ (\text{SUB}) & 10\ (\text{Sel4}) & 00 & 0 & 00 & 00 & 000101 & \mathbf{0x38014005} \\ \text{Step 5} & 00011\ (\text{Z}) & 01001\ (\text{ESP}) & 0010\ (\text{MAR}) & 000\ (\text{NOP}) & 00 & 00 & 0 & 00 & 00 & 000110 & \mathbf{0x1A480006} \\ \text{Step 6} & 00001\ (\text{PC}) & 00011\ (\text{MDR}) & 0000 & 000\ (\text{NOP}) & 00 & 10\ (\text{WR}) & 1 & 00 & 00 & 000111 & \mathbf{0x08C01407} \\ \text{Step 7} & 01000\ (\text{IRAF}) & 00001\ (\text{PC}) & 0000 & 000\ (\text{NOP}) & 00 & 00 & 0 & 00 & 00 & 000000 & \mathbf{0x40400000} \\ \hline \end{array}


Problem C: Stack Deallocation & Register Restoration — POP RAX

1. Problem Statement & Operational Semantics

Write the microprogram sequence for the instruction:
POP RAX\mathbf{POP\ RAX}
Note: The fetch instruction cycle (Steps 1–3) may be skipped.

  • Instruction Name: Pop Top of Stack into Register (POP\text{POP}).
  • Destination Register: RAX\text{RAX} (64-bit / 32-bit Accumulator).
  • Core Operations:
    1. Memory Read from Stack: Read the value from main memory currently pointed to by the stack pointer (MDR←[ESP]\text{MDR} \leftarrow [\text{ESP}]) and transfer it into register RAX\text{RAX}.
    2. Stack Pointer Increment: Increment the stack pointer (ESP←ESP+4\text{ESP} \leftarrow \text{ESP} + 4 in 32-bit mode or RSP←RSP+8\text{RSP} \leftarrow \text{RSP} + 8 in 64-bit mode) to deallocate the top stack slot.

2. Derivation: Sequential vs. Overlapped/Pipelined Execution

Implementation C.1: Sequential Execution (Straightforward Trace)
  1. Step 4: Initiate Memory Read from Current Stack Top

    • ESPout\text{ESP}_{out} drives current stack address onto bus.
    • MARin\text{MAR}_{in} latches the address.
    • The Control Unit asserts READ\text{READ} and waits for memory with WMFC\text{WMFC}.
    • RTL: ESPout,  MARin,  READ,  WMFC\text{ESP}_{out},\; \text{MAR}_{in},\; \text{READ},\; \text{WMFC}
  2. Step 5: Transfer Retrieved Data to RAX\text{RAX}

    • Memory data is placed onto bus via MDRout\text{MDR}_{out}.
    • Destination register RAX\text{RAX} latches data via RAXin\text{RAX}_{in}.
    • RTL: MDRout,  RAXin\text{MDR}_{out},\; \text{RAX}_{in}
  3. Step 6: Increment Stack Pointer

    • ESPout\text{ESP}_{out} drives current stack pointer to ALU Input B.
    • MUX selects constant 4 (Select4\text{Select4}).
    • ALU adds 4 (ADD\text{ADD}), latching updated address into Z\text{Z} (Zin\text{Z}_{in}).
    • RTL: ESPout,  Select4,  ADD,  Zin\text{ESP}_{out},\; \text{Select4},\; \text{ADD},\; \text{Z}_{in}
  4. Step 7: Update ESP\text{ESP} and Conclude

    • Zout\text{Z}_{out} drives updated pointer onto bus.
    • ESPin\text{ESP}_{in} updates the stack pointer. END\text{END} is asserted.
    • RTL: Zout,  ESPin,  END\text{Z}_{out},\; \text{ESP}_{in},\; \text{END}

Implementation C.2: Optimized / Pipelined Execution (Concurrent ALU & Memory Wait)

Because the ALU and internal bus are idle during the asynchronous memory read latency, the stack pointer increment can be overlapped directly inside Step 4 and Step 5:

  1. Step 4: Address Memory and Compute ESP+4\text{ESP}+4 Concurrently

    • ESPout\text{ESP}_{out} drives the current stack address onto the bus.
    • MARin\text{MAR}_{in} latches the address, and the memory READ\text{READ} signal is triggered.
    • Simultaneously, the ALU takes the bus value (ESP\text{ESP}), selects constant 4 (Select4\text{Select4}), adds them (ADD\text{ADD}), and latches ESP+4\text{ESP}+4 into Z\text{Z} (Zin\text{Z}_{in}).
    • RTL: ESPout,  MARin,  READ,  Select4,  ADD,  Zin\text{ESP}_{out},\; \text{MAR}_{in},\; \text{READ},\; \text{Select4},\; \text{ADD},\; \text{Z}_{in}
  2. Step 5: Update ESP\text{ESP} while Waiting for Memory

    • Zout\text{Z}_{out} drives ESP+4\text{ESP}+4 onto the bus.
    • ESPin\text{ESP}_{in} updates the stack pointer.
    • The Control Unit asserts WMFC\text{WMFC} to await completion of the memory read initiated in Step 4.
    • RTL: Zout,  ESPin,  WMFC\text{Z}_{out},\; \text{ESP}_{in},\; \text{WMFC}
  3. Step 6: Transfer Memory Data to Destination Register

    • MDRout\text{MDR}_{out} drives the popped value onto the bus.
    • RAXin\text{RAX}_{in} latches the value into the destination register. END\text{END} is asserted.
    • RTL: MDRout,  RAXin,  END\text{MDR}_{out},\; \text{RAX}_{in},\; \text{END}

Performance Gain: The optimized sequence reduces execution latency by 1 full clock cycle (3 cycles vs. 4 cycles) without introducing any hardware race conditions.


3. Microprogram Execution Table (Sequential vs. Optimized)

Sequential Schedule (4 Cycles):
StepCAR\text{CAR}Active Control SignalsRegister Transfer Language (RTL\text{RTL})Bus MasterBus ListenersFunctional Action
4000100ESPout,MARin,READ,WMFC\text{ESP}_{out}, \text{MAR}_{in}, \text{READ}, \text{WMFC}MAR←ESP,  READ,  WMFC\text{MAR} \leftarrow \text{ESP},\; \text{READ},\; \text{WMFC}ESP\text{ESP}MAR\text{MAR}Address stack top & read RAM
5000101MDRout,RAXin\text{MDR}_{out}, \text{RAX}_{in}RAX←MDR\text{RAX} \leftarrow \text{MDR}MDR\text{MDR}RAX\text{RAX}Transfer popped word to RAX\text{RAX}
6000110ESPout,Select4,ADD,Zin\text{ESP}_{out}, \text{Select4}, \text{ADD}, \text{Z}_{in}Z←ESP+4\text{Z} \leftarrow \text{ESP} + 4ESP\text{ESP}ALU Input BIncrement stack pointer by 4
7000111Zout,ESPin,END\text{Z}_{out}, \text{ESP}_{in}, \text{END}ESP←Z,  END\text{ESP} \leftarrow \text{Z},\; \text{END}Z\text{Z}ESP\text{ESP}Write back incremented ESP\text{ESP}, End
Optimized Overlapped Schedule (3 Cycles):
StepCAR\text{CAR}Active Control SignalsRegister Transfer Language (RTL\text{RTL})Bus MasterBus ListenersFunctional Action
4000100ESPout,MARin,READ,Select4,ADD,Zin\text{ESP}_{out}, \text{MAR}_{in}, \text{READ}, \text{Select4}, \text{ADD}, \text{Z}_{in}MAR←ESP,  READ,  Z←ESP+4\text{MAR} \leftarrow \text{ESP},\; \text{READ},\; \text{Z} \leftarrow \text{ESP} + 4ESP\text{ESP}MAR\text{MAR}, ALUParallel address latch & ALU increment
5000101Zout,ESPin,WMFC\text{Z}_{out}, \text{ESP}_{in}, \text{WMFC}ESP←Z,  WMFC\text{ESP} \leftarrow \text{Z},\; \text{WMFC}Z\text{Z}ESP\text{ESP}Latch ESPnew\text{ESP}_{new} while waiting for memory
6000110MDRout,RAXin,END\text{MDR}_{out}, \text{RAX}_{in}, \text{END}RAX←MDR,  END\text{RAX} \leftarrow \text{MDR},\; \text{END}MDR\text{MDR}RAX\text{RAX}Load popped data into RAX\text{RAX}, End

4. Binary Control Word Encodings (Sequential Schedule)

StepSRC_OUTDST1DST2ALUMUXMEMWCDBRADHex WordStep 400111 (ESP)00010 (MAR)0000000 (NOP)0001 (RD)100000001010x38800C05Step 500010 (MDR)00110 (RAX)0000000 (NOP)0000000000001100x11800006Step 600111 (ESP)000000000001 (ADD)10 (Sel4)00000000001110x3800C007Step 700011 (Z)01001 (ESP)0000000 (NOP)0000000000000000x1A400000\begin{array}{|c|c|c|c|c|c|c|c|c|c|c|c|} \hline \textbf{Step} & \textbf{SRC\_OUT} & \textbf{DST1} & \textbf{DST2} & \textbf{ALU} & \textbf{MUX} & \textbf{MEM} & \textbf{W} & \textbf{CD} & \textbf{BR} & \textbf{AD} & \textbf{Hex Word} \\ \hline \text{Step 4} & 00111\ (\text{ESP}) & 00010\ (\text{MAR}) & 0000 & 000\ (\text{NOP}) & 00 & 01\ (\text{RD}) & 1 & 00 & 00 & 000101 & \mathbf{0x38800C05} \\ \text{Step 5} & 00010\ (\text{MDR}) & 00110\ (\text{RAX}) & 0000 & 000\ (\text{NOP}) & 00 & 00 & 0 & 00 & 00 & 000110 & \mathbf{0x11800006} \\ \text{Step 6} & 00111\ (\text{ESP}) & 00000 & 0000 & 001\ (\text{ADD}) & 10\ (\text{Sel4}) & 00 & 0 & 00 & 00 & 000111 & \mathbf{0x3800C007} \\ \text{Step 7} & 00011\ (\text{Z}) & 01001\ (\text{ESP}) & 0000 & 000\ (\text{NOP}) & 00 & 00 & 0 & 00 & 00 & 000000 & \mathbf{0x1A400000} \\ \hline \end{array}


◇Python Simulation & Verification Suite

To guarantee the mathematical and architectural integrity of the microprogram sequences and binary control words, the following executable Python simulator implements the cycle-accurate single-bus state machine:

『』
PYTHON
"""
CSARCH2 Microprogram & Control Unit Verification Script
Simulates cycle-by-cycle micro-operations and verifies register state transitions.
"""

class SingleBusCPU:
    def __init__(self):
        self.regs = {
            "RAX": 0, "RBX": 0, "RCX": 0, "RDX": 0,
            "RSI": 0, "RDI": 0, "RSP": 0x1000, "ESP": 0x1000,
            "EDI": 0, "PC": 0x00401000, "MAR": 0, "MDR": 0,
            "IR": 0, "IRAF": 0, "IRDF": 0, "Y": 0, "Z": 0
        }
        self.memory = {}
        self.bus = 0

    def write_mem(self, addr, val):
        self.memory[addr] = val & 0xFFFFFFFF

    def read_mem(self, addr):
        return self.memory.get(addr, 0)

# Binary Encoding Definition
SRC_MAP = {
    "NONE": 0, "PCOUT": 1, "MDROUT": 2, "ZOUT": 3, "RSIOUT": 4,
    "RBXOUT": 5, "RAXOUT": 6, "ESPOUT": 7, "IRAFOUT": 8, "IRDFOUT": 9
}
DST_MAP = {
    "NONE": 0, "PCIN": 1, "MARIN": 2, "MDRIN": 3, "IRIN": 4, "YIN": 5,
    "RAXIN": 6, "RBXIN": 7, "EDIIN": 8, "ESPIN": 9
}
ALU_MAP = {"NOP": 0, "ADD": 1, "SUB": 2, "MUL": 3}
MUX_MAP = {"NONE": 0, "SELECTY": 1, "SELECT4": 2}
MEM_MAP = {"NOP": 0, "READ": 1, "WRITE": 2}

def encode_cw(src="NONE", dst1="NONE", dst2="NONE", alu="NOP", mux="NONE",
              mem="NOP", wmfc=0, cd=0, br=0, ad=0):
    return ((SRC_MAP[src] << 27) | (DST_MAP[dst1] << 22) | (DST_MAP[dst2] << 18) |
            (ALU_MAP[alu] << 15) | (MUX_MAP[mux] << 13) | (MEM_MAP[mem] << 11) |
            (wmfc << 10) | (cd << 8) | (br << 6) | ad)

# --- Test 1: LEA EDI, [ALPHA + RBX + RSI*4] ---
def verify_lea():
    cpu = SingleBusCPU()
    ALPHA = 0x00040000
    cpu.regs["IRAF"] = ALPHA
    cpu.regs["RBX"] = 0x00001000
    cpu.regs["RSI"] = 0x00000020
    
    # Step 4: RSIout, Select4, MUL, Zin
    cpu.bus = cpu.regs["RSI"]
    cpu.regs["Z"] = (cpu.bus * 4) & 0xFFFFFFFF
    # Step 5: Zout, Yin
    cpu.bus = cpu.regs["Z"]
    cpu.regs["Y"] = cpu.bus
    # Step 6: RBXout, SelectY, ADD, Zin
    cpu.bus = cpu.regs["RBX"]
    cpu.regs["Z"] = (cpu.bus + cpu.regs["Y"]) & 0xFFFFFFFF
    # Step 7: Zout, Yin
    cpu.bus = cpu.regs["Z"]
    cpu.regs["Y"] = cpu.bus
    # Step 8: IRAFout, SelectY, ADD, Zin
    cpu.bus = cpu.regs["IRAF"]
    cpu.regs["Z"] = (cpu.bus + cpu.regs["Y"]) & 0xFFFFFFFF
    # Step 9: Zout, EDIin
    cpu.bus = cpu.regs["Z"]
    cpu.regs["EDI"] = cpu.bus
    
    expected = ALPHA + 0x1000 + (0x20 * 4)
    assert cpu.regs["EDI"] == expected == 0x00041080
    print(f"[*] LEA Verification PASSED: EDI = 0x{cpu.regs['EDI']:08X}")

# --- Test 2: CALL L1 (Absolute) ---
def verify_call():
    cpu = SingleBusCPU()
    cpu.regs["PC"] = 0x00401050
    cpu.regs["ESP"] = 0x0012FF00
    cpu.regs["IRAF"] = 0x00405500
    
    # Step 4: ESPout, Select4, SUB, Zin
    cpu.bus = cpu.regs["ESP"]
    cpu.regs["Z"] = (cpu.bus - 4) & 0xFFFFFFFF
    # Step 5: Zout, ESPin, MARin
    cpu.bus = cpu.regs["Z"]
    cpu.regs["ESP"] = cpu.bus
    cpu.regs["MAR"] = cpu.bus
    # Step 6: PCout, MDRin, WRITE
    cpu.bus = cpu.regs["PC"]
    cpu.regs["MDR"] = cpu.bus
    cpu.write_mem(cpu.regs["MAR"], cpu.regs["MDR"])
    # Step 7: IRAFout, PCin
    cpu.bus = cpu.regs["IRAF"]
    cpu.regs["PC"] = cpu.bus
    
    assert cpu.regs["ESP"] == 0x0012FEFC
    assert cpu.read_mem(0x0012FEFC) == 0x00401050
    assert cpu.regs["PC"] == 0x00405500
    print(f"[*] CALL Verification PASSED: New PC = 0x{cpu.regs['PC']:08X}, Saved Ret = 0x{cpu.read_mem(0x0012FEFC):08X}")

# --- Test 3: POP RAX ---
def verify_pop():
    cpu = SingleBusCPU()
    cpu.regs["ESP"] = 0x0012FEFC
    cpu.write_mem(0x0012FEFC, 0xCAFEBABE)
    
    # Step 4: ESPout, MARin, READ
    cpu.bus = cpu.regs["ESP"]
    cpu.regs["MAR"] = cpu.bus
    cpu.regs["MDR"] = cpu.read_mem(cpu.regs["MAR"])
    # Step 5: MDRout, RAXin
    cpu.bus = cpu.regs["MDR"]
    cpu.regs["RAX"] = cpu.bus
    # Step 6: ESPout, Select4, ADD, Zin
    cpu.bus = cpu.regs["ESP"]
    cpu.regs["Z"] = (cpu.bus + 4) & 0xFFFFFFFF
    # Step 7: Zout, ESPin
    cpu.bus = cpu.regs["Z"]
    cpu.regs["ESP"] = cpu.bus
    
    assert cpu.regs["RAX"] == 0xCAFEBABE
    assert cpu.regs["ESP"] == 0x0012FF00
    print(f"[*] POP Verification PASSED: RAX = 0x{cpu.regs['RAX']:08X}, New ESP = 0x{cpu.regs['ESP']:08X}")

if __name__ == "__main__":
    verify_lea()
    verify_call()
    verify_pop()
    print("[+] ALL INSTRUCTIONS SYSTEMATICALLY VERIFIED!")

◇Key Takeaways & Synthesis

Comparative Summary Table

Metric / AttributeProblem A: LEA EDI, [...]Problem B: CALL L1Problem C: POP RAX (Sequential)Problem C: POP RAX (Optimized)
Instruction ClassData Movement / CalculationControl Transfer (Subroutine)Stack DeallocationStack Deallocation
Execution Phase Cycles6 Cycles (Steps 4–9)4 Cycles (Steps 4–7)4 Cycles (Steps 4–7)3 Cycles (Steps 4–6)
Memory Bus Operations0 (No RAM Access)1 Write ([ESPnew]←PC[\text{ESP}_{new}] \leftarrow \text{PC})1 Read (MDR←[ESP]\text{MDR} \leftarrow [\text{ESP}])1 Read (MDR←[ESP]\text{MDR} \leftarrow [\text{ESP}])
ALU Operations1×MUL,  2×ADD1 \times \text{MUL},\; 2 \times \text{ADD}1×SUB1 \times \text{SUB} (for ESP−4\text{ESP}-4)1×ADD1 \times \text{ADD} (for ESP+4\text{ESP}+4)1×ADD1 \times \text{ADD} (for ESP+4\text{ESP}+4)
Bus Contention RuleExactly 1 driver per cycleExactly 1 driver per cycleExactly 1 driver per cycleExactly 1 driver per cycle
Primary Risk / PitfallConfusing LEA\text{LEA} with MOV\text{MOV} (adding memory read)Forgetting stack grows down (SUB\text{SUB} vs ADD\text{ADD})Incrementing ESP\text{ESP} before reading RAMIncrementing ESP\text{ESP} before reading RAM

Critical Review & Exam Traps

  1. LEA\text{LEA} vs MOV\text{MOV} Trap: An effective address expression inside square brackets [...] looks identical for both MOV\text{MOV} and LEA\text{LEA}. However, MOV\text{MOV} loads the contents at that calculated memory address (requiring MARin,READ,WMFC,MDRout\text{MAR}_{in}, \text{READ}, \text{WMFC}, \text{MDR}_{out}), while LEA\text{LEA} loads the calculated address itself directly into the destination register (Zout,EDIin,ENDZ_{out}, \text{EDI}_{in}, \text{END}).
  2. Stack Growth Direction Trap: In the x86 architecture, the stack is a descending stack (Full-Descending). Therefore, PUSH/CALL\text{PUSH} / \text{CALL} uses SUB\text{SUB} with Select4\text{Select4} to decrement the stack pointer, whereas POP/RET\text{POP} / \text{RET} uses ADD\text{ADD} with Select4\text{Select4} to increment the stack pointer.
  3. Pipelining WMFC\text{WMFC}: While memory operations require external bus cycles (WMFC\text{WMFC}), the internal CPU bus and ALU are free during that interval. An optimized microprogram places independent ALU operations (such as pointer increments or counter updates) during the memory latency period to save execution cycles.

◇References & Navigation

[PS] Microprogramming and Control Unit | PROJECT ENGRAM